Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

no-scroll

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

no-scroll

Disable the document's scrolling

  • 1.1.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

no-scroll

Disable the document's scrolling.

It's silly how many libraries have their own implementation of this. So I thought I'd make a module that other libraries could use.

Here's how this works:

  • When you turn it on(), the document.body is styled with overflow: hidden and a padding-right that mimics the width of the scrollbar.
  • When you turn it off(), everything goes back to the way it was before.

Installation

npm install no-scroll

Dependencies: none.

Browser Support

IE9+

Not touchscreens (see Caveats below)

Usage

This module exposes two simple functions: on() and off().

var noScroll = require('no-scroll');

// To turn off the document's scrolling
noScroll.on();

// To restore scrolling
noScroll.off();

If you do not have a CommonJS environment (no module.exports), the module exposes the global object noScroll.

Caveats

I have not yet figured out or found an ideal way of stopping scrolling on touch devices. (The common practice of e.preventDefault() on touchmove events is too obstructive, at least for a library; for example, it disables scrolling of any element, not just the document.) Any big ideas? Please PR?

Keywords

FAQs

Package last updated on 17 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc